<template>
    <div class="listDiv">
        <div class="searchDiv">
            <el-select v-model="obj.req.verify" placeholder="状态" class="search_select" clearable>
                <el-option v-for="(item,index) in globalData.verifyTypeAry2" :key="index" :label="item.text" :value="item.value" />
            </el-select>
            <el-select v-model="obj.req.type" placeholder="类别" class="search_select" clearable>
                <el-option v-for="(item,index) in globalData.parkingTypeList" :key="index" :label="item.text" :value="item.value" />
            </el-select>
            <el-input clearable placeholder="匹配名称" v-model="obj.req.key" class="search_key" />
            <span class="btn search" @click="init">搜索</span>
            <span class="btn refresh" @click="obj.req.currentpage=1;init()"></span>
            <div class="searchRight">
            </div>
        </div>
        <div class="table_box"><div class="table_" id="tb">
            <ul class="head">
                <li class="mw300">申请企业</li>
                <li class="mw300">申请内容</li>
                <li class="wcen">车牌</li>
                <li class="">分配的车位</li>
                <li class="wcen">类别</li>
                <li class="mw200 wcen">申请时间</li>
                <li class="wcen">审核状态</li>
                <li class="mxw120 wcen">操作</li>
            </ul>
            <div class="body">
                <ul v-for="x in obj.ary" :key="x">
                    <li class="mw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.companyname" placement="top-start" :disabled="x.companyname.length<17">
                            <div class="lineOne pointer">{{x.companyname}}</div>
                        </el-tooltip>
                    </li>
                    <li class="mw300">
                        <el-tooltip class="box-item" effect="dark" :content="x.title" placement="top-start" :disabled="x.title.length<17">
                            <div class="lineOne pointer">{{x.title}}</div>
                        </el-tooltip>
                    </li>
                    <li class="wcen">{{x.plate}}</li>
                    <li class="">{{x.parking||'---'}}</li>
                    <li class="wcen">{{fix(x,'type')}}</li>
                    <li class="mw200 wcen">{{x.intime}}</li>    
                    <li class="wcen">
                        <div :class="[fix(x,'verify').label]">{{fix(x,'verify').text}}</div>
                    </li>
                    <li class="mxw120 wcen">
                        <el-button class="edit_btn" type="success" @click="edit(x)" :disabled="x.verify!=0">审核</el-button>
                    </li>
                </ul>
            </div>
        </div>
        </div><Pager :value="obj.req" :init="init" />

        <el-dialog v-model="obj.drawer.design" :title="obj.drawer.designTitle" width="1000px" :close-on-click-modal="false" :destroy-on-close="true">
            <router-view @close="obj.drawer.design = false" @init="init" />
        </el-dialog>
    </div>
</template>

<script setup>
    import { reactive, getCurrentInstance, ref, toRefs, provide, computed } from 'vue'
    import Pager from '@/components/pager.vue'
    import DelConfirm from '@/components/del_confirm.vue'
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        drawer: {
            design: false,
            designTitle: "",
        },
        ary: [],
        req: {
            currentpage: 1,
            pagesize: 10,
            count: 0,
            key: "",
            verify:"",
            type: ""
        }
    });
    let init = () => {
        proxy.$ajax({
            url: '/parking_apply/list',
            data: obj.req,
            bfLoading: true
        }).then(d => {
            // console.log(d)
            if(d.success){
                obj.ary = d.msg.list
                obj.req.count = d.msg.count
            }
        }).catch(() => { })
    }
    let fix = computed(() => {
        return (x,type) => {
            if(x[type] == 0) return (type==='type'?'不限':{text:'待审核',color:'warning-color',label:'label-btn-warning'})
            if(x[type] == 1) return (type==='type'?'固定':{text:'通过',color:'success-color',label:'label-btn-success'})
            if(x[type] == 2) return (type==='type'?'非固定':{text:'拒绝',color:'danger-color',label:'label-btn-error'})
        }
    })

    let editId = ref(0)
    provide("id", editId); //不能加.value
    let edit = x => {
        obj.drawer.design = true
        obj.drawer.designTitle = "审核车位申请"
        editId.value = x.parking_apply_id;
    }
</script>

<style scoped>
    ::-webkit-scrollbar { width:10px; background-color: #FFFFFF; }
    .search_select { width:100px!important; }
    .search_key { width:160px!important; }
    #tb ul li.li1 { width: 60px; }
    #tb ul li.li2 { width: 75px; }
    #tb ul li.li5 { width: 75px; }
    #tb ul li.li6 { width: 55px; }
    #tb ul li.li7 { width: 75px; }
</style>